<template>
  <div class="app-container">
    <loading v-show="loading"></loading>
    <el-card class="box-card searchFormStyle" style="margin-bottom:1%;">
      <div slot="header" class="clearfix">
        <span>考核周期操作</span>
      </div>
      <div class="text item">
        <el-form ref="searchData" :model="searchData" label-width="130px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="考核周期名称">
                <el-input v-model="searchData.assessmenYear"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <el-form-item>
                <el-button type="primary" 
                v-if="permissionHandle('partyMemberSatisfactionAssessment:getList')"
                icon="el-icon-search" 
                @click="getList">查 询</el-button>
                <el-button type="primary" 
                v-if="permissionHandle('partyMemberSatisfactionAssessment:getList')"
                icon="el-icon-refresh" 
                @click="resetSearch">重 置</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-card>
    <el-card class="box-card" style="margin-bottom:1%;">
        <div slot="header" class="clearfix">
          <span>考核周期列表</span>
        </div>
        <el-table
        :data="tableData"
        border
        ref="tableData"
        style="width: 100%;margin-bottom:1%;"
        >
        <el-table-column
          label="考核周期名称"
        >
          <template slot-scope="scope">
              {{ scope.row.assessmenYear }}
          </template>
        </el-table-column>
        <el-table-column
          label="考核开始时间"
        >
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            <span style="margin-left: 10px">{{ scope.row.assessmenBeginTime }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="考核结束时间"
        >
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            <span style="margin-left: 10px">{{ scope.row.assessmenEndTime }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="考核周期状态"
        >
          <template slot-scope="scope">
              {{ scope.row.releaseState }}
          </template>
        </el-table-column>
        <el-table-column
          label="创建日期"
          width="180"
        >
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            <span style="margin-left: 10px">{{ scope.row.createTime }}</span>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="150px">
          <template slot-scope="scope">
            <el-button
              size="mini"
              v-if="permissionHandle('partyMemberSatisfactionAssessment:evaluation')"
              icon="el-icon-document"
              @click="handleEdit(scope.$index, scope.row)">民主评议</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange" :paginations="paginations"></pagination>
    </el-card>
  </div>
</template>
<script>
import Loading from '@/components/loading/loading'
import pagination from '@/components/pagination/index'
import { getExamCircle } from '@/api/partyMember/partyMemberCircle'
export default {
  components: {
    Loading,
    pagination
  },
  data() {
    this.permissionHandle = this.$permissionHandle
    return {
      paginations: {
        totalNum: 0,
        currentPage: 1,
        pageSize: 10
      },
      searchData: {
        assessmenYear: '',
        pageSize: '10',
        pageNum: '1'
      },
      loading: false,
      tableData: [],
      detailD: {
        cycleAssessmenKey: ''
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    resetSearch() {
      this.searchData.assessmenYear = ''
      this.getList()
    },
    blurSearch() {
      this.getList()
    },
    getList() {
      this.searchData.pageNum = 1
      this.getCircleList()
      this.paginations.currentPage = 1
    },
    // 获取周期列表
    getCircleList() {
      this.loading = true
      return new Promise((resolve, reject) => {
        getExamCircle(this.searchData).then(response => {
          // console.log(this.SearchDep)
          this.tableData = response.data.items
          this.paginations.totalNum = parseInt(response.data.itemsTotalCount)
          resolve()
          this.loading = false
        }).catch(error => {
          this.loading = false
          reject(error)
        })
      })
    },

    handleEdit(index, row) {
      this.$router.push({
        path: 'partyMemberAssessment',
        name: '民主评议中',
        query: {
          parAssessmentKey: row.cycleAssessmenKey
        }
      })
    },

    // 改变分页的时候查询数据
    handleSizeChange(val) {
      this.searchData.pageSize = val
      this.getCircleList()
    },
    handleCurrentChange(val) {
      this.searchData.pageNum = val
      this.getCircleList()
    }
  }
}
</script>
<style lang="scss" scoped>
 .tree-select,.el-date-editor{width: 95%;}
 .el-input{width: 95%;}
 .delBtns{position: relative;left:20%;top:5px;}
.num{font-size: 18px;font-style: normal;font-weight: 700;}
.padding .el-card__header div{position: relative;}
  .padding .el-card__header .btn-box{position: absolute;right:0;top:50%;transform: translate(0 ,-50%)}

    
</style>
<style>
</style>


